package com.xjscrm.console.web.groupSend;

import com.xjscrm.console.param.groupSend.*;
import com.xjscrm.console.param.wwDevice.WwDeviceQuery;
import com.xjscrm.console.service.customer.groupSend.BatchGroupSendService;
import com.xjscrm.console.service.customer.groupSend.GroupSendService;
import com.xjscrm.console.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "高级群发管理", tags = "高级群发管理")
@RestController
@RequestMapping(value = "/groupSend")
public class GroupSendController {

    @Autowired
    private GroupSendService groupSendService;

    @Autowired
    private BatchGroupSendService batchGroupSendService;

    @ApiOperation(value = "新增群发任务", notes = "新增群发任务",response = Boolean.class)
    @PostMapping(value ="/addGroupSendTask" )
    public Object addGroupSendTask(@RequestBody GroupSendTaskDto groupSendTaskDto) throws Exception{
        groupSendService.addGroupSendTask(groupSendTaskDto);
        return true;
    }

    @ApiOperation(value = "获取任务中心列表", notes = "获取任务中心列表",response = GroupSendTaskVo.class)
    @PostMapping(value ="/getGroupSendTaskList" )
    public Object getGroupSendTaskList(@RequestBody GroupSendTaskQuery groupSendTaskQuery)throws Exception{
       return   groupSendService.getGroupSendTaskList(groupSendTaskQuery);
    }

    @ApiOperation(value = "获取任务中心任务详情", notes = "获取任务中心任务详情",response = GroupSendTaskVo.class)
    @PostMapping(value ="/getGroupSendTaskDetail" )
    public Object getGroupSendTaskDetail(@RequestBody GroupSendTaskDto groupSendTaskDto)throws Exception{
       return    groupSendService.getGroupSendTaskDetail(groupSendTaskDto);
    }


    @ApiOperation(value = "修改群发任务", notes = "修改群发任务",response = Boolean.class)
    @PostMapping(value ="/updateGroupSendTask" )
   public Object updateGroupSendTask(@RequestBody GroupSendTaskDto groupSendTaskDto)throws Exception{
        groupSendService.updateGroupSendTask(groupSendTaskDto);
        return true;
   }

    @ApiOperation(value = "开启或关闭任务", notes = "开启或关闭任务",response = Boolean.class)
    @PostMapping(value ="/startAndStop" )
   public Object startAndStop(@RequestBody StartAndStopDto startAndStopDto)throws Exception{
        groupSendService.startAndStop(startAndStopDto);
        return true;
   }

    @ApiOperation(value = "删除群发任务", notes = "删除群发任务",response = Boolean.class)
    @PostMapping(value ="/deleGroupSendTask" )
   public Object deleGroupSendTask(@RequestBody GroupSendTaskDto groupSendTaskDto) throws Exception{
        groupSendService.deleGroupSendTask(groupSendTaskDto);
        return true;
   }

    @ApiOperation(value = "获取群发任务机器人应用列表", notes = "获取群发任务机器人应用列表",response = GroupSendTaskDeviceConfigVo.class)
    @PostMapping(value ="/getDeviceList" )
    public Object getDeviceList(@RequestBody WwDeviceQuery wwDeviceQuery)throws Exception{
    return  groupSendService.getDeviceList(wwDeviceQuery);
   }

    @ApiOperation(value = "批量设置机器人应用列表休眠规则", notes = "批量设置机器人应用列表休眠规则",response = Boolean.class)
    @PostMapping(value ="/batchUpdateSleepRule" )
   public Object batchUpdateSleepRule(@RequestBody BatchUpdateSleepRuleDto batchUpdateSleepRuleDto)throws Exception{
        batchGroupSendService.batchUpdateSleepRule(batchUpdateSleepRuleDto);
        return true;
   }

    @ApiOperation(value = "获取任务列表", notes = "获取任务列表",response = GroupSendJobVo.class)
    @PostMapping(value ="/getGroupSendJobList" )
   public Object getGroupSendJobList(@RequestBody GroupSendJobQuery groupSendJobquery) throws Exception{
    return groupSendService.getGroupSendJobList(groupSendJobquery);
   }

    @ApiOperation(value = "获取任务列表发送详情", notes = "获取任务列表发送详情",response = GroupSendJobMsgVo.class)
    @PostMapping(value ="/getGroupSendJobMsgList" )
   public Object getGroupSendJobMsgList(@RequestBody GroupSendJobMsgQuery groupSendJobMsgQuery)throws Exception{
     return groupSendService.getGroupSendJobMsgList(groupSendJobMsgQuery);
   }

    @ApiOperation(value = "批量暂停任务", notes = "批量暂停任务",response = Boolean.class)
    @PostMapping(value ="/batchBreakGroupSendJob" )
   public Object batchBreakGroupSendJob(@RequestBody BatchGroupSendJobDto batchGroupSendJobDto)throws Exception{
        batchGroupSendService.batchBreakGroupSendJob(batchGroupSendJobDto);
        return true;
   }

    @ApiOperation(value = "批量继续任务", notes = "批量继续任务",response = Boolean.class)
    @PostMapping(value ="/batchContinueGroupSendJob" )
   public Object batchContinueGroupSendJob(@RequestBody BatchGroupSendJobDto batchGroupSendJobDto)throws Exception{
        batchGroupSendService.batchContinueGroupSendJob(batchGroupSendJobDto);
        return true;
   }

    @ApiOperation(value = "批量取消任务", notes = "批量取消任务",response = Boolean.class)
    @PostMapping(value ="/batchcancelGroupSendJob" )
   public Object batchCancelGroupSendJob(@RequestBody BatchGroupSendJobDto batchGroupSendJobDto)throws Exception{
        batchGroupSendService.batchCancelGroupSendJob(batchGroupSendJobDto);
        return true;
   }

    @ApiOperation(value = "批量删除任务", notes = "批量删除任务",response = Boolean.class)
    @PostMapping(value ="/batchDeleGroupSendJob" )
  public Object batchDeleGroupSendJob(@RequestBody BatchGroupSendJobDto batchGroupSendJobDto)throws Exception{
        batchGroupSendService.batchDeleGroupSendJob(batchGroupSendJobDto);
        return true;
  }
}
